<html>
<head><meta charset="utf-8"><title>global_asm interpolation design decision · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/global_asm.20interpolation.20design.20decision.html">global_asm interpolation design decision</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241347664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/global_asm%20interpolation%20design%20decision/near/241347664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ruster <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/global_asm.20interpolation.20design.20decision.html#241347664">(Jun 03 2021 at 04:37)</a>:</h4>
<p>I don't know a lot about <code>global_asm</code> but I found this example:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="cp">#![feature(global_asm)]</span><span class="w"></span>
<span class="fm">global_asm!</span><span class="p">{</span><span class="s">r#"</span>
<span class="s">// ${num}</span>
<span class="s">/* ${num} */</span>
<span class="s">"#</span><span class="p">}</span><span class="w"></span>
</code></pre></div>
<p><code>${x}</code> kind of looks like formatting. Why was <code>${}</code> chosen instead of <code>{}</code> like you usually see it?</p>



<a name="241358126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/global_asm%20interpolation%20design%20decision/near/241358126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/global_asm.20interpolation.20design.20decision.html#241358126">(Jun 03 2021 at 07:48)</a>:</h4>
<div class="codehilite"><pre><span></span><code>error: there is no argument named `num`
 --&gt; src/lib.rs:3:5
  |
3 | // ${num}
  |     ^^^^^
</code></pre></div>
<p>If you look at the error message you will see that the <code>{num}</code> part is highlighted and not <code>${num}</code>. It still gives this error with <code>$</code>, so it seems that the syntax is <code>{}</code> and not <code>${}</code>.</p>



<a name="241361154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/global_asm%20interpolation%20design%20decision/near/241361154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> ruster <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/global_asm.20interpolation.20design.20decision.html#241361154">(Jun 03 2021 at 08:24)</a>:</h4>
<p>Ah, that makes sense. Indeed, it seems that was just the user having some kind of habit and so they added those dollar signs. That was confusing.</p>



<a name="241399256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/global_asm%20interpolation%20design%20decision/near/241399256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/global_asm.20interpolation.20design.20decision.html#241399256">(Jun 03 2021 at 14:36)</a>:</h4>
<p>I think <code>$</code> means an immediate value in asm. So <code>${num}</code> where <code>num</code> is 4 is the immediate value 4.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>